//
//  THDeployWiFiViewController.m
//  TaiHao
//
//  Created by rzm on 16/6/7.
//  Copyright © 2016年 rzm. All rights reserved.
//

#import "SampuxDeployWiFiViewController.h"
#import "SampuxDeployWiFiView.h"
#import "SampuxAddEquipMentSucessVC.h"
#import "SampuxAddEquipMentFaithVC.h"
@interface SampuxDeployWiFiViewController ()
@property (nonatomic, strong)  SampuxDeployWiFiView *deplyWiFiView ;

@end

@implementation SampuxDeployWiFiViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
//    [self createBackBarButtonItem];
    [self.navigationItem setHidesBackButton:YES];
    [self createWifiView];
}

- (void)createWifiView
{
    _deplyWiFiView = [[SampuxDeployWiFiView alloc]initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height)];
    _deplyWiFiView.numberStr = self.numStr;
    [self.view addSubview:_deplyWiFiView];
    
    __weak typeof(SampuxDeployWiFiViewController *) wSelf = self;
    _deplyWiFiView.nextSuccessBlock = ^(NSString *accountStr){
        dispatch_async(dispatch_get_main_queue(), ^{
            SampuxAddEquipMentSucessVC *sucessVC = [[SampuxAddEquipMentSucessVC alloc]init];
            sucessVC.numStr = accountStr;
            [wSelf.navigationController pushViewController:sucessVC animated:YES];
        });
    };
    
    _deplyWiFiView.nextFailBlock = ^(NSString *accountStr){
        SampuxAddEquipMentFaithVC *faithVC = [[SampuxAddEquipMentFaithVC alloc]init];
        faithVC.account = accountStr;
        [wSelf.navigationController pushViewController:faithVC animated:YES];
    };
    
    _deplyWiFiView.nextListBlock = ^{
        [wSelf.navigationController popToRootViewControllerAnimated:YES];
    };
    
//    _deplyWiFiView.progressBlock = ^(BOOL isProgressIng) {
//
//        SampuxCustomNavController *nav = (SampuxCustomNavController *)wSelf.navigationController;
//        if (isProgressIng == YES) {
//            nav.button.userInteractionEnabled = NO;
//        }else
//        {
//            nav.button.userInteractionEnabled = YES;
//        }
//    };
}

- (void)setNumStr:(NSString *)numStr
{
    _numStr = numStr;
    self.deplyWiFiView.numberStr = _numStr;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    SampuxCustomNavController *nav = (SampuxCustomNavController *)self.navigationController;
    nav.titleStr = @"WiFi配置";
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:YES];
    [self.deplyWiFiView.loadView removeFromSuperview];
}

@end
